import { http } from '@/utils/request'
import type {
  UserRegisterRequest,
  UserLoginRequest,
  UserLoginResponse,
  UserProfileResponse,
  UserUpdateRequest,
  User
} from '@/types/api'

// 用户注册
export const register = (data: UserRegisterRequest): Promise<User> => {
  return http.post('/api/v1/register', data)
}

// 用户登录
export const login = (data: UserLoginRequest): Promise<UserLoginResponse> => {
  return http.post('/api/v1/login', data)
}

// 获取用户资料
export const getProfile = (): Promise<UserProfileResponse> => {
  return http.get('/api/v1/profile')
}

// 更新用户资料
export const updateProfile = (data: UserUpdateRequest): Promise<User> => {
  return http.put('/api/v1/profile', data)
}

// 用户登出
export const logout = (): Promise<void> => {
  return http.post('/api/v1/logout')
}
